package o;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.hwid.core.constants.HwAccountConstants;

public abstract class dzr<P, R> {
    private o.dzr.WorkHandler ˊ = new o.dzr.WorkHandler(Looper.getMainLooper());
    private int ˋ = 0;
    private dzr ˎ;
    private boolean ˏ;
    private String ॱ;

    static class WorkHandler extends Handler {
        public WorkHandler(Looper looper) {
            super(looper);
        }

        public void handleMessage(Message message) {
            super.handleMessage(message);
        }
    }

    protected abstract R ˎ(P p);

    protected abstract String ॱ();

    public dzr(boolean z) {
        this.ˏ = z;
    }

    public void ˎ(boolean z) {
        this.ˏ = z;
    }

    public boolean ˊ() {
        return this.ˏ;
    }

    protected void ˋ() {
        String ˋ = eok.ˎ().ˋ();
        if (TextUtils.isEmpty(ˋ)) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " interrupt()====================  msgKey: " + this.ॱ);
        } else {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " interrupt()====================  msgKey: " + this.ॱ + ", trace: " + ˋ);
            dzl.ˋ("213", ˋ);
        }
        this.ˋ = 3;
        ʻ();
    }

    protected void ˏ() {
        String ˋ = eok.ˎ().ˋ();
        if (TextUtils.isEmpty(ˋ)) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " interrupt()====================  msgKey: " + this.ॱ);
        } else {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " interrupt()====================  msgKey: " + this.ॱ + ", trace: " + ˋ);
            dzl.ˋ("213", ˋ);
        }
        this.ˋ = 3;
        ˎ(eok.ˎ().ˏ());
    }

    protected void ˎ() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " pause() ");
        this.ˋ = 2;
    }

    public void ˋ(P p) {
        flowStart();
        Object ˎ = ˎ((Object) p);
        if (ॱˊ()) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " needContinue ");
            ˊ(ˎ);
        }
    }

    private boolean ॱˊ() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " needContinue() status=" + this.ˋ);
        if (1 == this.ˋ) {
            return true;
        }
        return false;
    }

    protected void ˊ(final R r) {
        flowEnd();
        if (this.ˎ != null) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " nextFlow ");
            this.ˊ.post(new Runnable(this) {
                final /* synthetic */ dzr ˋ;

                public void run() {
                    this.ˋ.ˎ.ˋ(r);
                }
            });
            return;
        }
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " all of the flows end! ");
        ʽ();
    }

    protected void flowStart() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " begin==================== ");
        this.ˋ = 1;
    }

    protected void flowEnd() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " end==================== ");
        this.ˋ = 999;
    }

    public void nextFlow(dzr o_dzr) {
        this.ˎ = o_dzr;
        this.ˎ.ˏ(ʼ());
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " mNextFlow getMsgKey=" + o_dzr.ʼ());
    }

    protected void ʽ() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " sendFlowEndBroadcast msgKey=" + this.ॱ);
        dzv.ˊ(false);
        if (UserSession.getInstance().isLoginSuccessful() && dir.ˋ().ˏ() && ˊ()) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " reportSignResult true.");
            ccx.ˎ(true, null);
        }
        ˎ(false);
        dqr.ˏ(new dqx(ContentManager.getInstant().getContext()));
        Intent intent = new Intent("com.huawei.appmarket.startup.flow.end");
        intent.putExtra(this.ॱ, this.ॱ);
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
    }

    protected void ˎ(String str) {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " sendFlowErrorBroadcast msgKey=" + this.ॱ);
        dzv.ˊ(false);
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " setSignedForUser false.");
        ccx.ˏ(eqp.ॱ(), false);
        ˎ(false);
        Intent intent = new Intent("com.huawei.appmarket.startup.flow.error");
        intent.putExtra(this.ॱ, this.ॱ);
        intent.putExtra(HwAccountConstants.EXTRA_OPLOG_ERROR, str);
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
    }

    protected void ʻ() {
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " sendExitBroadcast msgKey=" + this.ॱ);
        dzv.ˊ(false);
        Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " setSignedForUser false.");
        ccx.ˏ(eqp.ॱ(), false);
        ˎ(false);
        Intent intent = new Intent("com.huawei.appmarket.startup.flow.interrupt");
        intent.putExtra(this.ॱ, this.ॱ);
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
    }

    public String ʼ() {
        return this.ॱ;
    }

    public void ˏ(String str) {
        this.ॱ = str;
    }
}
